//
//  WDPersonalSettingNewViewCell.m
//  wd-serviceapp
//
//  Created by Bin Tang on 2025/3/18.
//

#import "WDPersonalSettingNewViewCell.h"

@interface WDPersonalSettingNewViewCell ()
@property (nonatomic, strong) TYZCommonCellModel *model;
@property (nonatomic, strong) UILabel *titleLabel;
//@property (nonatomic, strong) UIImageView *thanImgView;
@property (nonatomic, strong) UILabel *valueLabel;
@property (nonatomic, strong) CALayer *bottomLine;
@end

@implementation WDPersonalSettingNewViewCell

- (void)initWithSubViewCell {
    CGRect frame = CGRectMake(kRealValue(20), self.height - 1, kScreenW - kRealValue(20) * 2, 1);
    self.bottomLine = [CALayer drawLine:self frame:frame lineColor:[UIColor colorWithHexString:@"#EEEEEE"]];
}

- (void)initWithTitleLabel
{
    if (!_titleLabel) {
        NSString *str = @"交付中心大家";
        UIFont *font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
        float width = [str widthForFont:font];
        CGRect frame = CGRectMake(kRealValue(20), (kWDPersonalSettingNewViewCellHeight - 30) * 0.5, width, 30);
        _titleLabel = [UILabel createWithLabel:self frame:frame font:font propertiesBlock:^(UILabel * _Nonnull label) {
            label.textColor = [UIColor colorWithHexString:@"#000000"];
        }];
    }
    if (self.model) {
        self.titleLabel.text = self.model.title;
    }
}

- (void)initWithThanImgView {
    
    
    
//    if (!_thanImgView) {
//        UIImage *image = [UIImage imageNamed:@"ic_than_more_99"];
//        CGRect frame = CGRectMake(self.width - 20 - image.size.width, (self.height - image.size.height) * 0.5, image.size.width, image.size.height);
//        _thanImgView = [[UIImageView alloc] initWithFrame:frame];
//        _thanImgView.image = image;
//        [self addSubview:_thanImgView];
//    }
}

/// 值
- (void)initWithValueLabel {
    if (!_valueLabel) {
        CGRect frame = self.titleLabel.frame;
        frame.origin.x = self.titleLabel.right + 2;
//        frame.size.height = 30;
        UIImage *image = [UIImage imageNamed:@"ic_than_more_99"];
        frame.size.width = (kScreenW - 20 - image.size.width) - 8 - self.titleLabel.right - 2;
        _valueLabel = [UILabel createWithLabel:self frame:frame font:[UIFont systemFontOfSize:14 weight:UIFontWeightRegular] propertiesBlock:^(UILabel * _Nonnull label) {
            label.textAlignment = NSTextAlignmentRight;
//            label.text = @"请选择";
            label.textColor = [UIColor colorWithHexString:@"#000000"];
            label.numberOfLines = 0;
        }];
        
//        @weakify(self);
//        _valueLabel.userInteractionEnabled = YES;
//        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id  _Nonnull sender) {
//            @strongify(self);
//            if (self.viewBlock) {
//                self.viewBlock(nil);
//            }
//        }];
//        [_valueLabel addGestureRecognizer:tap];
        
    }
    if (self.model) {
        self.valueLabel.height = self.model.valueHeight;
        self.valueLabel.text = objectNull(self.model.value);
    }
}

- (void)updateCellData:(id)cellEntity {
    self.model = cellEntity;
    
    [self initWithTitleLabel];
    
    [self initWithValueLabel];
    
    self.bottomLine.top = self.contentView.height - 1;
}


@end
